package com.jic.market.controller.manage;

import com.jic.common.base.vo.RestResult;
import com.jic.market.api.manage.PromotionRuleApi;
import com.jic.market.request.PromotionRuleRequest;
import com.jic.market.response.PromotionRuleResponse;
import com.jic.market.service.PromotionRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author guohuayong
 * @date: 2020年02月20日
 */
@RestController
@RequestMapping("/promotionRule")
public class PromotionRuleController implements PromotionRuleApi {
    @Autowired
    PromotionRuleService promotionRuleService;

    @PostMapping("/findAll")
    @Override
    public RestResult<List<PromotionRuleResponse>> list(@RequestBody PromotionRuleRequest.PromotionRuleListRequest listRequest) {
        return RestResult.success(promotionRuleService.findAll(listRequest));
    }

    @PostMapping("/saveBatch")
    @Override
    public RestResult<Integer> saveBatch(@RequestBody PromotionRuleRequest request) {
        return RestResult.success(promotionRuleService.saveBatch(request));
    }

    @Override
    @PostMapping("/update")
    public RestResult<Integer> update(@RequestBody PromotionRuleRequest.PromotionRuleListRequest request) {
        return RestResult.success(promotionRuleService.update(request));
    }

    @Override
    @PostMapping("/save")
    public RestResult<List<PromotionRuleResponse>> save(@RequestBody PromotionRuleRequest.PromotionRuleListRequest request) {
        return RestResult.success(promotionRuleService.save(request));
    }
    @Override
    @PostMapping("/delete")
    public RestResult<List<PromotionRuleResponse>> delete(@RequestBody PromotionRuleRequest.PromotionRuleListRequest request) {
        return RestResult.success(promotionRuleService.delete(request));
    }

}
